package demo;

import java.util.List;

import model.University;
import model.User;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.data.repository.core.support.RepositoryFactorySupport;
import org.springframework.test.context.ContextConfiguration;

import repository.UniversityRepository;

@Configuration
@ComponentScan
@EnableAutoConfiguration
@ContextConfiguration
public class Application {
	private static final Logger logger = Logger.getLogger(Application.class);
	
	@Autowired
	private static UniversityRepository universityRepository;
	
    public static void main(String[] args) {
        ApplicationContext appContext = new ClassPathXmlApplicationContext("/beans.xml");
        MongoOperations mongoOperation = (MongoOperations) appContext.getBean("mongoTemplate");
        UniversityService universityService = (UniversityService)appContext.getBean("universityService");
        Page<University> result = universityService.findAll(new PageRequest(0,10));
        for(University university:result){
        	logger.info("name " + university.getName());
        }
    }
}
